use ops::{self, BuildOutput, ExecEngine};
use sources::PathSource;
use util::config::Config;
-use util::{CargoResult, profile};
+use util::{CargoResult, profile, human, ChainError};
/// Contains information about how a package should be compiled.
pub struct CompileOptions<'a> {
// The path listed next to the string is the config file in which the
// key was located, so we want to pop off the `.cargo/config` component
// to get the directory containing the `.cargo` folder.
- p.parent().unwrap().parent().unwrap().join(s)
- }).filter(|p| {
+ (p.parent().unwrap().parent().unwrap().join(s), p)
+ }).filter(|&(ref p, _)| {
// Make sure we don't override the local package, even if it's in the
// list of override paths.
cur_path != &**p
});
- for path in paths {
+ for (path, definition) in paths {
let id = try!(SourceId::for_path(&path));
let mut source = PathSource::new_recursive(&path, &id, config);
- try!(source.update());
+ try!(source.update().chain_error(|| {
+ human(format!("failed to update path override `{}` \
+ (defined in `{}`)", path.display(),
+ definition.display()))
+ }));
registry.add_override(&id, Box::new(source));
}
Ok(())
{compiling} b v0.5.0 ([..])
", compiling = COMPILING)));
});
+
+test!(missing_path_dependency {
+ let p = project("foo")
+ .file("Cargo.toml", r#"
+ [project]
+ name = "a"
+ version = "0.5.0"
+ authors = []
+ "#)
+ .file("src/lib.rs", "")
+ .file(".cargo/config", r#"
+ paths = ["../whoa-this-does-not-exist"]
+ "#);
+ p.build();
+ assert_that(p.cargo("build"),
+ execs().with_status(101)
+ .with_stderr("\
+failed to update path override `[..]../whoa-this-does-not-exist` \
+(defined in `[..]`)
+
+Caused by:
+ failed to read directory `[..]`
+
+Caused by:
+ [..] (os error [..])
+"));
+});